<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Timer App</title>
    <style>
        body {
            background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('https://source.unsplash.com/1920x1080/?nature,calm') no-repeat center center fixed;
            background-size: cover;
            color: #fff;
            font-family: Arial, sans-serif;
            text-align: center;
            display: flex;
            flex-direction: column;
            height: 100vh;
            margin: 0;
        }
        #menu {
            background-color: #333;
            padding: 5px;
            display: flex;
            justify-content: center;
            align-items: center;
            position: relative;
            transition: all 0.3s ease;
        }
        .minimized #menu {
            position: absolute;
            top: auto;
            bottom: 10px;
            left: 50%;
            transform: translateX(-50%);
            background: none;
            z-index: 1002;
        }
        #timer {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            transition: all 0.3s ease;
        }
        .minimized #timer {
            transform: scale(0.8);
            margin: 10px;
        }
        .minimized #timer-input,
        .minimized #start,
        .minimized #pause,
        .minimized #reset {
            display: none;
        }
        .minimized #marquee {
            display: none;
        }
        .minimized #timer {
            transform: scale(0.7);
            margin-top: -20px;
        }
        .minimized #time {
            font-size: 36px;
        }
        .minimized progress {
            width: 200px;
            height: 15px;
        }
        .toggle-button {
            position: relative;
            z-index: 1002;
            background-color: rgba(76, 175, 80, 0.8);
            border: none;
            color: white;
            padding: 6px 12px;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 5px;
            width: 100px;
            writing-mode: horizontal-tb;
        }
        .toggle-button:hover {
            background-color: rgba(69, 160, 73, 0.9);
            transform: scale(1.05);
        }
        .minimized #marquee {
            display: none;
        }
        .minimized #timer {
            transform: scale(0.7);
            margin-top: -20px;
        }
        .minimized #time {
            font-size: 36px;
        }
        .minimized progress {
            width: 200px;
            height: 15px;
        }
        #settings-dropdown {
            display: none; /* 初始状态隐藏 */
            position: absolute;
            top: 100%;
            background-color: #333;
            color: #fff;
            padding: 10px;
            border-radius: 5px;
            z-index: 1000;
        }
        #settings {
            position: relative;
            cursor: pointer;
        }
        #settings-menu {
            display: none;
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: #333;
            color: #fff;
            padding: 20px;
            border-radius: 5px;
            z-index: 1000;
        }
        .toggle-button {
            position: relative;
            z-index: 1002;
            background-color: rgba(76, 175, 80, 0.8);
            border: none;
            color: white;
            padding: 6px 12px;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 12px;
            display: flex;
            align-items: center;
            gap: 5px;
        }
        .toggle-button:hover {
            background-color: rgba(69, 160, 73, 0.9);
            transform: scale(1.05);
        }
        .minimized #marquee {
            display: none;
        }
        .minimized #timer {
            transform: scale(0.7);
            margin-top: -20px;
        }
        .minimized #time {
            font-size: 36px;
        }
        .minimized progress {
            width: 200px;
            height: 15px;
        }
        #settings-menu input {
            margin: 10px 0;
            padding: 10px;
            font-size: 16px;
            width: calc(100% - 22px);
            border-radius: 8px;
            border: 1px solid #ddd;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            transition: all 0.3s ease;
        }
        #settings-menu button {
            margin: 5px;
            padding: 10px 20px;
            font-size: 16px;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        #settings-menu button:hover {
            background-color: #45a049;
        }
        #timer {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }
        #time {
            font-size: 48px;
            margin-bottom: 20px;
            font-family: 'Courier New', monospace;
            color: #000000;
            text-shadow: 0 0 10px rgba(0, 255, 255, 0.7),
                       0 0 20px rgba(0, 255, 255, 0.5),
                       0 0 30px rgba(0, 255, 255, 0.3);
            transition: all 0.3s ease;
        }
        progress {
            width: 80%;
            height: 20px;
            margin-bottom: 20px;
            border: none;
            border-radius: 10px;
            background: rgba(0, 0, 0, 0.2);
            overflow: hidden;
        }
        progress::-webkit-progress-bar {
            background: rgba(0, 0, 0, 0.2);
            border-radius: 10px;
        }
        progress::-webkit-progress-value {
            background: linear-gradient(90deg, #00ffff, #0066ff);
            box-shadow: 0 0 10px rgba(0, 255, 255, 0.7);
            border-radius: 10px;
            animation: pulse 2s infinite;
        }
        @keyframes pulse {
            0% {
                box-shadow: 0 0 10px rgba(0, 255, 255, 0.7);
            }
            50% {
                box-shadow: 0 0 20px rgba(0, 255, 255, 0.9);
            }
            100% {
                box-shadow: 0 0 10px rgba(0, 255, 255, 0.7);
            }
        }
        #timer-input {
            width: auto;
            padding: 10px 20px;
            font-size: 16px;
            margin-bottom: 20px;
            border-radius: 8px;
            border: 1px solid #ddd;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            transition: all 0.3s ease;
        }
        button {
            margin: 5px;
            padding: 10px 20px;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s ease;
            border-radius: 8px;
            border: none;
            background-color: #4CAF50;
            color: white;
            box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        }
        button:hover {
            background-color: #45a049;
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
        }
        #timer-input:focus, #settings-menu input:focus {
            outline: none;
            border-color: #4CAF50;
            box-shadow: 0 2px 8px rgba(76,175,80,0.3);
        }
        #marquee {
            background-color: #333;
            color: #fff;
            padding: 20px; /* 增加 padding 以加大底部区域 */
            overflow: hidden;
            white-space: nowrap;
            position: relative;
            z-index: 1001; /* 确保字幕在最上层 */
        }
        #marquee-text {
            position: absolute;
            white-space: nowrap;
            left: 50%;
            transform: translateX(-50%); /* 通过 transform 居中 */
            color: #4CAF50;
        }
    </style>
</head>
<body>
    <div id="menu">
        <select id="settings">
            <option value="">设置</option>
            <option value="edit-marquee">编辑字幕</option>
        </select>
        <button id="toggle-size" class="toggle-button">
            <span>🔄</span> 最小化
        </button>
        <div id="settings-menu">
            <input type="text" id="marquee-input" placeholder="输入字幕内容">
            <div>
                <button id="submit-marquee">提交</button>
                <button id="cancel-marquee">取消</button>
            </div>
        </div>
    </div>
    <div id="timer">
        <span id="time">00:00:00</span>
        <progress id="progress-bar" value="0" max="100"></progress>
        <input type="number" id="timer-input" placeholder="输入定时时间（秒）" min="1">
        <div>
            <button id="start">开始</button>
            <button id="pause">暂停</button>
            <button id="reset">重置</button>
        </div>
    </div>
    <div id="marquee">
        <span id="marquee-text">又是美好的一天</span>
    </div>
    <script src="marquee.js"></script>
    <script>
        window.onload = function() {
            let timer;
            let seconds = 0;
            let isPaused = false;
            let totalSeconds = 0;
            const progressBar = document.getElementById('progress-bar');
            const timerInput = document.getElementById('timer-input');

            function updateTime() {
                const hrs = Math.floor(seconds / 3600);
                const mins = Math.floor((seconds % 3600) / 60);
                const secs = seconds % 60;
                document.getElementById('time').textContent = 
                    `${hrs.toString().padStart(2, '0')}:${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
                
                // 更新进度条
                progressBar.value = (seconds / totalSeconds) * 100;
                if (seconds >= totalSeconds) {
                    clearInterval(timer);
                    timer = null;
                    
                    // 播放提示音
                    const audio = new Audio('data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQwAEaYLWfkWgAI0wWs/ItAAAGDgYtAgAyN+QWaAAihwMWm4G8QQRDiMcCBcH3Cc+CDv/7xA4Tvh9Rz/y8QADBwMWgQAZG/ILNAARQ4GLTcDeIIIhxGOBAuD7hOfBB3/94gcJ3w+o5/5eIAIAAAVwWgQAVQ2ORaIQwEMAJiDg95G4nQL7mQVWI6GwRcfsZAcsKkJvxgxEjzFUgfHoSQ9Qq7KNwqHwuB13MA4a1q/DmBrHgPcmjiGoh//EwC5nGPEmS4RcfkVKOhJf+WOgoxJclFz3kgn//dBA+ya1GhurNn8zb//9NNutNuhz31f////9vt///z+IdAEAAAK4LQIAKobHItEIYCGAExBwe8jcToF9zIKrEdDYIuP2MgOWFSE34wYiR5iqQPj0JIeoVdlG4VD4XA67mAcNa1fhzA1jwHuTRxDUQ//iYBczjHiTJcIuPyKlHQkv/L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v3uvmReDl0UnvtapVaIzo1jZbf/pD6ElLqSX+rUmOQNpJFa/r+sa4e/pBlAABoAAAAA3CUgShLdGIxsY7AUABPRrgCABdDuQ5GC7DqPQCgbbJUAoRSUj+NIEig0YfyWUho1VBBBA//uQZB4ABZx5zfMakeAAAAmwAAAAF5F3P0w9GtAAACfAAAAAwLhMDmAYWMgVEG1U0FIGCBgXBXAtfMH10000EEEEEECUBYln03TTTdNBDZopopYvrTTdNa325mImNg3TTPV9q3pmY0xoO6bv3r00y+IDGid/9aaaZTGMuj9mpu9Mpio1dXrr5HERTZSmqU36A3CumzN/9Robv/Xx4v9ijkSRSNLQhAWumap82WRSBUqXStV/YcS+XVLnSS+WLDroqArFkMEsAS+eWmrUzrO0oEmE40RlMZ5+ODIkAyKAGUwZ3mVKmcamcJnMW26MRPgUw6j+LkhyHGVGYjSUUKNpuJUQoOIAyDvEyG8S5yfK6dhZc0Tx1KI/gviKL6qvvFs1+bWtaz58uUNnryq6kt5RzOCkPWlVqVX2a/EEBUdU1KrXLf40GoiiFXK///qpoiDXrOgqDR38JB0bw7SoL+ZB9o1RCkQjQ2CBYZKd/+VJxZRRZlqSkKiws0WFxUyCwsKiMy7hUVFhIaCrNQsKkTIsLivwKKigsj8XYlwt/WKi2N4d//uQRCSAAjURNIHpMZBGYiaQPSYyAAABLAAAAAAAACWAAAAApUF/Mg+0aohSIRobBAsMlO//Kk4soosy1JSFRYWaLC4qZBYWFRGZdwqKiwkNBVmoWFSJkWFxX4FFRQWR+LsS4W/rFRb/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////VEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU291bmRib3kuZGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjAwNGh0dHA6Ly93d3cuc291bmRib3kuZGUAAAAAAAAAACU=');
                    audio.play();
                    
                    // 显示桌面通知
                    if (Notification.permission === "granted") {
                        new Notification("计时结束", {
                            body: "您设置的时间已到！",
                            icon: "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><defs><linearGradient id='grad' x1='0%' y1='0%' x2='100%' y2='100%'><stop offset='0%' style='stop-color:rgb(0,255,255);stop-opacity:1' /><stop offset='100%' style='stop-color:rgb(0,102,255);stop-opacity:1' /></linearGradient></defs><circle cx='50' cy='50' r='45' fill='url(%23grad)' stroke='white' stroke-width='2'/><circle cx='50' cy='50' r='3' fill='white'/><path d='M50 25 L50 50 L65 65' stroke='white' stroke-width='4' stroke-linecap='round' fill='none'/></svg>"
                        });
                    } else if (Notification.permission !== "denied") {
                        Notification.requestPermission().then(permission => {
                            if (permission === "granted") {
                                new Notification("计时结束", {
                                    body: "您设置的时间已到！",
                                    icon: "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><defs><linearGradient id='grad' x1='0%' y1='0%' x2='100%' y2='100%'><stop offset='0%' style='stop-color:rgb(0,255,255);stop-opacity:1' /><stop offset='100%' style='stop-color:rgb(0,102,255);stop-opacity:1' /></linearGradient></defs><circle cx='50' cy='50' r='45' fill='url(%23grad)' stroke='white' stroke-width='2'/><circle cx='50' cy='50' r='3' fill='white'/><path d='M50 25 L50 50 L65 65' stroke='white' stroke-width='4' stroke-linecap='round' fill='none'/></svg>"
                                });
                            }
                        });
                    }
                    
                    // 弹出提示框
                    alert("定时时间到！");
                }
            }

            timerInput.addEventListener('change', (event) => {
                totalSeconds = parseInt(event.target.value, 10) || 100;
                progressBar.max = 100; // 确保进度条最大值为100
                seconds = 0; // 重置计时
                updateTime();
            });

            document.getElementById('start').addEventListener('click', () => {
                if (!timer && totalSeconds > 0) { // 确保只有在输入有效时间后才能开始计时
                    timer = setInterval(() => {
                        if (!isPaused) {
                            seconds++;
                            updateTime();
                        }
                    }, 1000);
                }
            });

            document.getElementById('pause').addEventListener('click', () => {
                isPaused = !isPaused;
            });

            document.getElementById('reset').addEventListener('click', () => {
                clearInterval(timer);
                timer = null;
                seconds = 0;
                updateTime();
            });

            document.getElementById('settings').addEventListener('change', (event) => {
                if (event.target.value === 'edit-marquee') {
                    document.getElementById('settings-menu').style.display = 'block';
                } else if (event.target.value === 'minimize') {
                    document.body.classList.toggle('minimized');
                    event.target.value = '';
                }
            });

            document.getElementById('submit-marquee').addEventListener('click', () => {
                const marqueeText = document.getElementById('marquee-input').value || "又是美好的一天";
                document.getElementById('marquee-text').textContent = marqueeText;
                document.getElementById('settings-menu').style.display = 'none';
                document.getElementById('settings').value = ''; // 重置下拉框
            });

            document.getElementById('cancel-marquee').addEventListener('click', () => {
                document.getElementById('settings-menu').style.display = 'none';
                document.getElementById('settings').value = ''; // 重置下拉框
                document.getElementById('marquee-input').value = ''; // 清空输入框内容
            });

            const toggleSizeBtn = document.getElementById('toggle-size');
            toggleSizeBtn.innerHTML = '<span>🔄</span> 最小化';
            
            toggleSizeBtn.addEventListener('click', () => {
                document.body.classList.toggle('minimized');
                const isMinimized = document.body.classList.contains('minimized');
                toggleSizeBtn.innerHTML = isMinimized ? '<span>🔄</span> 最大化' : '<span>🔄</span> 最小化';
                
                if (isMinimized) {
                    window.electron.minimize();
                } else {
                    window.electron.restore();
                }
            });
            
            // 监听窗口大小变化
            window.electron.onWindowSizeChanged((event, size) => {
                const isMinimized = size.width <= 300 && size.height <= 200;
                document.body.classList.toggle('minimized', isMinimized);
                toggleSizeBtn.innerHTML = isMinimized ? '<span>🔄</span> 最大化' : '<span>🔄</span> 最小化';
            });

            updateTime();
        };
    </script>
</body>
</html>